package com.souku.finance.application.base;

import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.view.WindowManager;

import com.souku.finance.application.R;
import com.souku.finance.application.ui.MainActivity;
import com.souku.finance.application.utils.Constant;
import com.souku.finance.application.ui.lock.LockActivity;
import com.souku.finance.application.ui.lock.LockSetupActivity;
import com.souku.finance.application.utils.ShareUtil;
import com.souku.finance.application.utils.ViewUtil;
import com.souku.finance.application.http.volley.ServiceTimeHelper;

/**
 * Created by Android on 2016/12/5.
 */

public class BaseFragmentActivity extends FragmentActivity {

    @Override
    public void setContentView(int layoutResID) {
        super.setContentView(layoutResID);
        ViewUtil.setColor(this, getResources().getColor(R.color.main));
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        }
    }

    @Override
    protected void onResume() {
        //获取服务器时间
        new ServiceTimeHelper(this).getTime();
        MainActivity.isBackstage = false;
        if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
//        if (ShareUtil.getInstance().getBoolean(Constant.IsLogin)) {
//            if (ShareUtil.getInstance().getString(Constant.GesturePass) == null) {
//                Intent intent = new Intent(this, LockSetupActivity.class);
//                startActivity(intent);
//            }
//        }
//        if (MainActivity.islock) {
//            if (System.currentTimeMillis() - MainActivity.lockTime > 30 * 1000) {
//                Intent intent = new Intent(this, LockActivity.class);
//                startActivity(intent);
//            }
//        }
        MainActivity.islock = false;
        super.onResume();
    }
}
